'use strict';

angular.module('com.dcos.app').controller('ConfigDetailController',function($window,$scope,$uibModalInstance,config_id,Upload,reload,ConfigService) {
  var vm = this;
  vm.curProjectId=$window.sessionStorage.getItem("curProjectId");

  vm.config={
    "id":"",
    "project_id":vm.curProjectId,
    "config_name":"",
    "file_path":"",
    "config_content":"",
    "status":"1"
  };
  vm.configFile=[];
  vm.addFile=function(event){
    vm.configFile=event.target.files;
  }

  vm.ok = function () {
    vm.config.file=vm.configFile;
    Upload.upload({
      url: '/v1/conf/add',
      data: vm.config
    }).then(function(response){
      reload();
      $uibModalInstance.dismiss('cancel');
    }, function(err){

    });
  }

  vm.cancel = function () {
    $uibModalInstance.dismiss('cancel');
  };
});
